
import Vue from 'vue';
import VueRouter from 'vue-router';
import IndexView from "@/views/IndexView.vue";
import { children } from "@/router/children_router";
import LoginsView from "@/views/LoginsView.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    component: LoginsView,
  },
  {
    path: '/IndexView',
    redirect: '/BannerView', // 这里你可能需要调整为实际的子路由路径
    component: IndexView,
    children: children,

  },
];

const router = new VueRouter({
  routes
});

// // 路由导航守卫
// router.beforeEach((to, from, next) => {
//   const token = localStorage.getItem('token'); // 假设你的 token 存储在 localStorage 中
//   console.log('token',token)
//
//   if ( !token) {
//     next('/BannerView'); // 如果需要认证且有 token，则直接跳转到 BannerView 页面
//   } else {
//     next(); // 允许用户继续访问当前页面
//   }
// });

export default router;
